<?php
// +----------------------------------------------------------------------
// | saiadmin [ saiadmin快速开发框架 ]
// +----------------------------------------------------------------------
// | Author: your name
// +----------------------------------------------------------------------
namespace app\financeInstitution\model;

use app\cassification\model\ClassificationDictionary;
use plugin\saiadmin\basic\BaseNormalModel;

/**
 * 机构列表模型
 */
class financeInstitution extends BaseNormalModel
{

    /**
     * 数据表主键
     * @var string
     */
    protected $pk = 'institution_id';

    /**
     * 数据库表名称
     * @var string
     */
    protected $table = 'eb_finance_institution';
    protected $append = ['finance_category_text'];



    /**
     * 金融机构名称 搜索
     */
    public function searchInstitutionNameAttr($query, $value)
    {
        $query->where('institution_name', 'like', '%'.$value.'%');
    }


    public function getFinanceCategoryTextAttr($value,$data)
    {
        if(isset($data['finance_category'])){
            return    ClassificationDictionary::where('dictionary_id', $data['finance_category'])->value('classification_name_zh');
        }
        return '';
    }

}
